home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rwvector.lha / RWVector2.1 / rw / Timer.h < prev    next >
C/C++ Source or Header  |  1989-08-18  |  987b  |  58 lines

  1. #ifndef TIMER_H
  2. #define TIMER_H
  3. #pragma once
  4.  
  5. /*
  6.  *    
  7.  *    Written by
  8.  *
  9.  *    Bruce Eckel
  10.  *    School of Oceanography; WB-10
  11.  *    University of Washington
  12.  *    Seattle, WA 98195
  13.  *
  14.  *    @(#)Timer.h    2.1    8/18/89
  15.  */
  16.  
  17. #include <sys/time.h>
  18. #include <sys/resource.h>
  19. #include <stream.h>
  20. #ifdef __GNUG__
  21. #include <std.h>
  22. #endif
  23. #ifdef __ATT__
  24. #include <string.h>
  25. #endif
  26.  
  27. /* 
  28. -*++ class timer: measures use of system resources
  29. ** 
  30. ** (*++ history: 
  31. **     27 Apr 88    Bruce Eckel    Creation date
  32. ** ++*)
  33. ** 
  34. ** (*++ detailed: Whenever you want to measure a point, use the "mark"
  35. ** function.  Everything will be dumped out at the end when you're done. 
  36. ** ++*)
  37. */
  38.  
  39. struct MarkPoint {
  40.     float seconds;
  41.     char * msg;
  42.     MarkPoint * next;
  43. };
  44.  
  45. class Timer {
  46.     MarkPoint * head;
  47.     MarkPoint * current;
  48.     void timer_(float * secs);
  49.   public: 
  50.     Timer();
  51.     ~Timer();
  52.     void mark();
  53.     void mark(char * msg);
  54.     friend ostream& operator<<(ostream &, Timer & );  /* send to stream */
  55. };
  56.  
  57. #endif TIMER_H
  58.